package ai;

import game.Game;

public class Position
{
	private int column;
	private int strength;
	private int depth;
	private int[][] playingField;
	
	
	//Om minmax mee aan te roepen
	public Position(int[][] playingField, boolean makeCopy)
	{
		if (makeCopy)
		{
			this.setPlayingField(playingField);
		}
		else
		{
			this.playingField = playingField;
		}
	}
	
	//Voor de basecase return in de minmax functie
	public Position(int strength, int depth, int[][] playingField, boolean makeCopy)
	{
		this.strength = strength;
		this.depth = depth;
		
		if (makeCopy)
		{
			this.setPlayingField(playingField);
		}
		else
		{
			this.playingField = playingField;
		}
	}
	
	//Voor de niet basecase return in de minmax functie
	public Position(int column, int strength, int depth, int[][] playingField, boolean makeCopy)
	{
		this.column = column;
		this.strength = strength;
		this.depth = depth;
		
		if (makeCopy)
		{
			this.setPlayingField(playingField);
		}
		else
		{
			this.playingField = playingField;
		}
	}
	
	
	private void setPlayingField(int[][] p)
	{
		this.playingField = new int[Game.XSIZE][Game.YSIZE];
		
		for (int x = 0; x < Game.XSIZE; x++)
		{
			for (int y = 0; y < Game.YSIZE; y++)
			{
				this.playingField[x][y] = p[x][y];
			}
		}
	}
	
	public boolean equals(Object o)
	{
		if (! (o instanceof Position))
			return false;

		Position other = (Position) o;
		if (this.column != other.column && this.strength != other.strength)
			return false;

		return true;
	}

	public int getColumn()
	{
		return column;
	}
	public int getStrength()
	{
		return strength;
	}

	public void setDepth(int d)
	{
		this.depth = d;
	}
	public int getDepth()
	{
		return this.depth;
	}
	public int[][] getPlayingField()
	{
		return playingField;
	}
	
	public String toString()
	{
		String output = "Postion object contents:\n";
		output += "	Column: "+this.column+"\n";
		output += "	Strength: "+this.strength+"\n";
		output += "	Depth: "+this.depth+"\n";
		output += "	PlayingField:\n";
		
		for (int y = 0; y < Game.YSIZE; y++)
		{
			output += "		";
			for (int x = 0; x < Game.XSIZE; x++)
			{
				output += this.playingField[x][y];
			}
			output += "\n";
		}
		
		
		return output;
	}
}
